package cn.nexd.app.collector.activity;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.umeng.analytics.MobclickAgent;

import java.io.File;

import cn.nexd.app.collector.R;
import cn.nexd.framework.util.SDCardUtil;

/**
 * Created by wangxu on 16/10/8.
 */

public class FileViewActivity extends AppCompatActivity {

    ListView listView;

    private final String STRING_TYPE_ERROR = "error";
    private final String STRING_TYPE_COLLECT = "collect";

    private String path = SDCardUtil.getSDCardPath()  + File.separator + "/nexd/error/";

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        Intent intent = getIntent();
        setContentView(R.layout.file_view);


        listView = (ListView) findViewById(R.id.fileView);
        String view = intent.getStringExtra("view");
        // 加载不同目录下的文件  异步加载文件目录并显示在UI上。
        if ("error".equals(view)) {

            listView.setOnItemClickListener(new ListViewItemOnClickListener(view));
        } else {

        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }


    private class BackgroundLoadFile extends AsyncTask {

        @Override
        protected Object doInBackground(Object[] params) {

            return null;
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);

        }
    }

    private class ListViewItemOnClickListener implements AdapterView.OnItemClickListener {

        private String ViewType;

        public ListViewItemOnClickListener(String viewType) {
            ViewType = viewType;
        }

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (STRING_TYPE_ERROR.equals(ViewType)){

            }
        }
    }
}
